
#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
#endregion

namespace SunwellRenderer.Rendering
{
	public static class QuadRenderComponent
	{
		static readonly short[] ib	= new short[] { 0,1,2,1,3,2 };
		static readonly VertexPositionTexture[] verts	= null;
		static QuadRenderComponent()
		{
			verts	= new VertexPositionTexture[]
			{
				new VertexPositionTexture(new Vector3(-1,1,0),new Vector2(0,0)),
				new VertexPositionTexture(new Vector3(1,1,0),new Vector2(1,0)),
				new VertexPositionTexture(new Vector3(-1,-1,0),new Vector2(0,1)),
				new VertexPositionTexture(new Vector3(1,-1,0),new Vector2(1,1)),
			};
		}

		static VertexDeclaration vertexDecl	= null;
		public static void Render(GraphicsDevice device)
		{
			if(vertexDecl == null)
				vertexDecl	= new VertexDeclaration(device,VertexPositionTexture.VertexElements);
			device.VertexDeclaration = vertexDecl;
			device.DrawUserIndexedPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList,verts,0,4,ib,0,2);
		}
	}
}
